import request from '@/utils/request'
import upload from '@/utils/upload'

// 登录
export function login(data) {
	return request({
		url: '/auth/mall/login',
		headers: {
			isToken: false
		},
		method: 'POST',
		loading: true,
		data
	})
}

// 获取用户详细信息
export function getInfo() {
	return request({
		url: '/system/user/info',
		method: 'GET'
	})
}

// 退出
export function logout() {
	return request({
		url: '/auth/login/out',
		method: 'GET'
	})
}

// 获取验证码
export function getAuthCode(phone) {
	return request({
		url: '/auth/sendCode/' + phone,
		headers: {
			isToken: false
		},
		method: 'POST',
		loading: true
	})
}

// 编辑用户详细信息
export function editInfo(data) {
	return request({
		url: '/system/user/edit/info',
		method: 'PUT',
		data
	})
}

// 文件上传
export function uploadFile(data, loading = true) {
	return upload({
		url: '/file/fileannex/upload',
		loading,
		formData: {filename: data.filename},
		name: data.name,
		filePath: data.filePath
	})
}